﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using LEEAAttendanceControl.Web;
using LEEAAttendanceControl.General;
using System.ServiceModel.DomainServices.Client;

namespace LEEAAttendanceControl.Views
{
    public partial class Departments : Page
    {
        public Departments()
        {
            InitializeComponent();
         
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void LnkEditDepartment_Click(object sender, RoutedEventArgs e)
        {
            Department currdep = GRDDepartment.SelectedItem as Department;
            DepartmentEdit depedit = new DepartmentEdit();
            depedit.LoadData(currdep != null ? currdep.DepartmentID : No.Zero);
            depedit.Closed += new EventHandler(DepartmentEdit_Closed);
            depedit.Show();
        }
        void DepartmentEdit_Closed(object sender, EventArgs e)
        {
            DepartmentDataSource.Load();
        }
       
        private void DepartmentDataSource_LoadingData_1(object sender, LoadingDataEventArgs e)
        {
            e.LoadBehavior = LoadBehavior.RefreshCurrent;
        }

        private void ImgNewDepartmen_Click(object sender, RoutedEventArgs e)
        {
            DepartmentEdit depedit = new DepartmentEdit();
            depedit.LoadData(No.Zero);
            depedit.Closed += new EventHandler(DepartmentEdit_Closed);
            depedit.Show();
      
        }

        private void LnkDeleteDepartment_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show(ApplicationStrings.DeleteMessage, ApplicationStrings.Delete, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                DepartmentDataSource.DataView.Remove(GRDDepartment.SelectedItem);
                DepartmentDataSource.SubmitChanges();
            }
        }

        

    }
}
